package idempotence

type Idempotence struct {
	generator Generator
	storage   Storage
}

func New(generator Generator, storage Storage) *Idempotence {
	return &Idempotence{
		generator: generator,
		storage:   storage,
	}
}

func (i *Idempotence) SaveIfAbsent(id string) (bool, error) {
	return i.storage.SaveIfAbsent(id)
}

func (i *Idempotence) Delete(id string) error {
	return i.storage.Delete(id)
}

func (i *Idempotence) Generate() (string, error) {
	return i.generator.Generate()
}
